package org.example.managementsystem.service;

import org.example.managementsystem.model.ProviderApplication;
import org.example.managementsystem.repository.ProviderApplicationDao;
import org.example.managementsystem.repository.ProviderApplicationReviewDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 供应商申请服务层
 * @author 王振祎
 * @date 2025-05-20
 */
@Service
public class ProviderApplicationService {
    
    private ProviderApplicationDao providerApplicationDao;

    @Autowired
    public ProviderApplicationService(ProviderApplicationReviewDao providerApplicationReviewDao, ProviderApplicationDao providerApplicationDao) {
        this.providerApplicationDao = providerApplicationDao;
    }

    /**
     * 提交供应商申请
     */
    public int submitApplication(ProviderApplication application) {
        return providerApplicationDao.insertApplication(application);
    }

    /**
     * 更新供应商申请
     */
    public int updateApplication(ProviderApplication application) {
        return providerApplicationDao.updateApplication(application);
    }

    /**
     * 获取所有供应商申请
     */
    public List<ProviderApplication> getAllApplications() {
        return providerApplicationDao.getAllApplications();
    }

    /**
     * 获取所有未审核的申请
     */
    public List<ProviderApplication> getAllUnapprovedApplications() {
        return providerApplicationDao.getAllUnapprovedApplications();
    }

    /**
     * 根据ID获取申请
     */
    public ProviderApplication getApplicationById(int applicationId) {
        return providerApplicationDao.getApplicationById(applicationId);
    }

    /**
     * 根据id删除申请
     */
    public int deleteApplication(int applicationId) {
        return providerApplicationDao.deleteApplication(applicationId);
    }

}
